<!--
 * @Descripttion: 
 * @Author: xiaodong
 * @Date: 2020-11-26 14:32:00
 * @LastEditTime: 2020-11-26 14:47:40
 * @FilePath: \cloud-monitor-sdk\example\iframe.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div>
    <iframe id='iframe' src='./index.html'></iframe>
    <button onclick="C()">开启/关闭</button>
</div>
  <script>
    window.addEventListener('message', function(event) {
      console.log(event.data.path)
    }, false)

    var iframe = document.getElementById('iframe').contentWindow
    let circle = true
    function C() {
      iframe.postMessage(circle, '*')
      circle = !circle
    }

  </script>
</body>
</html>